import { map, Observable, Subject } from "rxjs";
import { SrHttpUploadServerTask } from "../http/sr.http.upload.server.task";
import { V3proSubjectMessage } from "../../v3pro-task/model/v3pro.model";

/**
 * 文件上传操作符
 * 1. 将 message.files 上传到服务器
 * 2. 获取上传后返回的 id 并注入到 message.files[].id;
 */
export const uploadFile$ = map((group$: Observable<V3proSubjectMessage>) => {
  const subject = new Subject<V3proSubjectMessage>();
  const uploadServer = new SrHttpUploadServerTask(group$, subject);
  uploadServer.start().then();
  return subject;
});
